//
//  ReceiptAddressViewController.m
//  Mall
//
//  Created by 孙飞燕 on 16/10/20.
//  Copyright © 2016年 孙飞燕. All rights reserved.
//

#import "ReceiptAddressViewController.h"
#import "ReceptAddressTableViewCell.h"
#import "ChangeAddressViewController.h"
@interface ReceiptAddressViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataSourceArr;
@end

@implementation ReceiptAddressViewController
- (NSMutableArray *)dataSourceArr{
    if (!_dataSourceArr) {
        _dataSourceArr = [[NSMutableArray alloc]init];

    }
    return _dataSourceArr;
}
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.frame];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        //注册cell
        [_tableView registerNib:[UINib nibWithNibName:@"ReceptAddressTableViewCell" bundle:nil] forCellReuseIdentifier:@"ReceptAddressTableViewCell"];

        _tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    self.navigationItem.title = @"管理收货地址";
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    ReceptAddressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReceptAddressTableViewCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor groupTableViewBackgroundColor];

    [cell.editBtn addTarget:self action:@selector(editAction:) forControlEvents:UIControlEventTouchUpInside];
    [cell.deleteBtn addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];

    return cell;
}

//编辑按钮的点击方法
- (void)editAction:(UIButton *)sender{
    ChangeAddressViewController *addressVC = [[ChangeAddressViewController alloc]init];
    [self.navigationController pushViewController:addressVC animated:YES];
}
//删除按钮的点击方法
- (void)deleteAction:(UIButton *)sender{


}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 150;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
